<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<link rel="stylesheet" href="/resources/bootstrap/css/bootstrap-datetimepicker.min.css" />
		<style>
#accountInfo .box-header {
	padding: 19px;
}

#statistics .box-title {
	font-size: 16px;
}

#vol p:nth-child(2) {
	font-size: 15px;
}

select {
	color: black;
}

.ui-autocomplete-input {
	width: 100%;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class='full-center-content-scroll-noheader'>
			<div class="nav-tabs-custom">
				<h:form id="form">
					<p:growl id="msgs" showDetail="true" />
					<div class="tab-content no-padding">
						<div class="chart tab-pane active" id="stations" style="position: relative">
							<div class="box box-primary box-solid with-border">
								<div class="box-header">
									<h3 class="box-title">选择查询条件【上次统计时间：#{protectionEquipmentCountController.updateTime}】</h3>
									<div class="box-tools pull-right">
										<button class="btn btn-default btn-sm" data-widget="collapse">
											<i class="fa fa-minus"></i>
										</button>
									</div>
								</div>
								<div class="box-body">
									<!--查询body  -->
									<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
										<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
											icon="ui-icon-check" />
										<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
											icon="ui-icon-close" />
									</p:confirmDialog>
									<p:commandButton id="editBtn" value="编辑" icon="ui-icon-pencil" update="editForm:editPanel"
										disabled="#{protectionEquipmentCountController.selectDTO == null}" 
										oncomplete="PF('editDialog').show()" style="float: left; margin-right:5px;margin-left:5px" />
									<div style="float: left; height: 30px; line-height: 30px; margin-left: 10px;">
										<p:selectManyCheckbox id="box"
											value="#{protectionEquipmentCountController.selectedVoltageArray}">
											<f:selectItem itemLabel="35kV" itemValue="35" />
											<f:selectItem itemLabel="110kV" itemValue="110" />
											<f:selectItem itemLabel="220kV" itemValue="220" />
											<f:selectItem itemLabel="500kV" itemValue="500" />
											<f:selectItem itemLabel="全部" itemValue="全部" />
										</p:selectManyCheckbox>
									</div>
									<h:selectOneMenu id="statisticalDimension"
										value="#{protectionEquipmentCountController.statisticalDimension}"
										style="width:130px;margin-right:20px;height:30px">
										<f:selectItem itemLabel="调管单位" itemValue="0" />
										<f:selectItem itemLabel="检修单位" itemValue="1" />
										<f:selectItem itemLabel="生产厂家" itemValue="3" />
									</h:selectOneMenu>
									<p:remoteCommand name="changeYearAnalysis"
										actionListener="#{protectionEquipmentCountController.changeYear}" />
									<p:outputLabel value="年份:" />
									<input type="text" id="yearAnalysis" onchange="chaneYearAnalysis()"
										style="width: 60px; margin-left: 5px; text-align: center" />
									<p:commandButton value="查询" icon="ui-icon-search" update="table "
										actionListener="#{protectionEquipmentCountController.queryByStatisticalDimensionAndYear}"
										style="margin-left:10px;">
									</p:commandButton>
									<p:commandButton icon="ui-icon-refresh" value="重置"
										actionListener="#{protectionEquipmentCountController.resetQueryCriteria}"
										style="margin-left:5px;" update=" table statisticalDimension box" />
									<p:commandButton id="reCountBtn" style="float: right;margin-right:10px;" value="实时统计"
										actionListener="#{protectionEquipmentCountController.reStatistic}" icon="fa fa-refresh"
										update="editBtn  table">
										<p:confirm header="提示" message="重新统计会覆盖当前已存在的数据， 将从cim数据中进行统计。该操作不可回退确定要继续执行吗？"
											icon="ui-icon-alert" />
									</p:commandButton>
									<p:selectBooleanCheckbox style="float: right;margin-top:7px;color:blue"
										itemLabel="是否覆盖修改数据" value="#{protectionEquipmentCountController.reStatisticStatus}" />

								</div>
							</div>
							<div class="box box-primary box-solid with-border" style="text-align: center">
								<!--datatable  -->
								<p:dataTable id="table" var="item" rowKey="#{item.id}"
									value="#{protectionEquipmentCountController.list}" emptyMessage="无纪录"
									selectionMode="single" selection="#{protectionEquipmentCountController.selectDTO}">
									<p:ajax update=" :form:editBtn   " event="rowSelect"
										listener="#{protectionEquipmentCountController.onRowSelect}" />
									<p:column groupRow="true" headerText="名称" style="text-align:center">
										<h:outputText value="#{item.unitName}" />
									</p:column>
									<p:column headerText="电压等级" style="text-align:center">
										<h:outputText value="#{item.voltage}" />
									</p:column>
									<p:column headerText="线路、辅助保护" style="text-align:center">
										<h:outputText value="#{item.lineProCount}" />
									</p:column>
									<p:column headerText="母线保护" style="text-align:center">
										<h:outputText value="#{item.busProCount}" />
									</p:column>
									<p:column headerText="变压器保护" style="text-align:center">
										<h:outputText value="#{item.transformerProCount}" />
									</p:column>
									<p:column headerText="发电机保护" style="text-align:center">
										<h:outputText value="#{item.alternatorProCount}" />
									</p:column>
									<p:column headerText="电抗器保护" style="text-align:center">
										<h:outputText value="#{item.reactorProCount}" />
									</p:column>
									<p:column headerText="串补保护" style="text-align:center">
										<h:outputText value="#{item.seriesCompensationProCount}" />
									</p:column>
									<p:column headerText="短引线保护" style="text-align:center">
										<h:outputText value="#{item.shortLeadProCount}" />
									</p:column>
									<p:column headerText="断路器保护" style="text-align:center">
										<h:outputText value="#{item.breakerProCount}" />
									</p:column>
									<p:column headerText="汇总" style="text-align:center">
										<h:outputText value="#{item.summary}" />
									</p:column>
									<!-- <p:column headerText="录波器保护" style="text-align:center">
										<h:outputText value="#{item.recorderProCount}" />
									</p:column> -->
									<p:columnGroup type="footer">
										<p:row style="font-weight:bold">
											<p:column colspan="2" style="text-align:right;background-color:#3C8DBC;color:#fff"
												footerText="汇总:" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('0')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('1')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('2')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('3')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('4')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('5')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('6')}  台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('7')} 台" />
											<p:column style="text-align:center;background-color:#3C8DBC;color:#fff"
												footerText="#{protectionEquipmentCountController.summaryMap.get('10')} 台" />
										</p:row>
									</p:columnGroup>
								</p:dataTable>
							</div>
						</div>
					</div>
				</h:form>
				<h:form id="editForm">
					<p:dialog id="editDialog" widgetVar="editDialog" modal="true" header="编辑统计参数" width="380"
						height="450">
						<p:toolbar>
							<f:facet name="left">
								<p:commandButton value="保存" update="form:table" oncomplete="PF('editDialog').hide()"
									actionListener="#{protectionEquipmentCountController.saveProtectionDeviceCountDTO()}" />
								<p:commandButton value="取消" onclick="PF('editDialog').hide()" />
							</f:facet>
						</p:toolbar>
						<p:panelGrid columns="2" id="editPanel">
							<p:outputLabel value="单位" />
							<p:outputLabel value="#{protectionEquipmentCountController.selectDTO.unitName}"
								readonly="true" />
							<p:outputLabel value="线路、辅助保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.lineProCount}" />
							<p:outputLabel value="母线保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.busProCount}" />
							<p:outputLabel value="变压器保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.transformerProCount}" />
							<p:outputLabel value="发电机保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.alternatorProCount}" />
							<p:outputLabel value="电抗器保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.reactorProCount}" />
							<p:outputLabel value="串补保护保护数量" />
							<p:inputText
								value="#{protectionEquipmentCountController.selectDTO.seriesCompensationProCount}" />
							<p:outputLabel value="短引线保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.shortLeadProCount}" />
							<p:outputLabel value="断路器保护数量" />
							<p:inputText value="#{protectionEquipmentCountController.selectDTO.breakerProCount}" />
						</p:panelGrid>
					</p:dialog>
				</h:form>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="#{request.contextPath}/resources/bootstrap/js/bootstrap-datetimepicker.min.js" />
		<script>
			var d = new Date();
			var currentYear = d.getFullYear();
			$("#year").val(currentYear);
			$('#year').datetimepicker({
				startView : 4,
				minView : 4,
				autoclose : true,
				format : 'yyyy'
			});
		</script>
		<script>
			$(function() {
				var d = new Date();
				var currentYear = d.getFullYear();
				$("#year").val(currentYear);
				$('#year').datetimepicker({
					startView : 4,
					minView : 4,
					autoclose : true,
					format : 'yyyy'
				});

				$("#yearAnalysis").val(currentYear);
				$('#yearAnalysis').datetimepicker({
					startView : 4,
					minView : 4,
					autoclose : true,
					format : 'yyyy'
				});

			});

			function chaneYearAnalysis() {
				var year = $("#yearAnalysis").val();
				changeYearAnalysis([ {
					name : 'yearAnalysis',
					value : year
				} ]);
			}
		</script>
	</ui:define>
</ui:composition>
